package cn.life.common.utils;

import cn.life.common.entity.model.MyUserInfo;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author 李佳明
 * @Date 2018-07-24 14:23
 */
public class RequestPoSetUtil {

    public static Class<?> setOprData(Object obj, MyUserInfo myUserInfo) throws IllegalAccessException {
        Map<String, Object> map = new HashMap<>();
        Class<?> clazz = obj.getClass();
        for (Field field : clazz.getDeclaredFields()) {
            field.setAccessible(true);
            String fieldName = field.getName();
            Object value = field.get(obj);
            switch (fieldName){
                case "oprUserId" : obj.getClass(); break;
                case "oprUserName" : value =  myUserInfo.getUserName(); break;
                case "oprDate" : value =  new Date(); break;
                default: break;
            }
            map.put(fieldName, value);
        }
        return (obj.getClass());
    }
}
